require "Cocos2d"
require "AudioEngine"
local visibleSize = cc.Director:getInstance():getVisibleSize()
local visibleOrigin = cc.Director:getInstance():getVisibleOrigin()

local GameState = {nomal=1, think=2, showFinal=3, sleep=4}

local game_1_2_1_1_Scene = class("game_1_2_1_1_Scene",function ()
    return cc.Layer:create()
end)
game_1_2_1_1_Scene._perScene=nil
game_1_2_1_1_Scene.__index=game_1_2_1_1_Scene
function game_1_2_1_1_Scene:createScene()
    require "gameScene"
    local layer = game_1_2_1_1_Scene:create()
    layer._perScene = gameSceneInstance
    return layer
end

function game_1_2_1_1_Scene:create()
    local layer = game_1_2_1_1_Scene:new()
    return layer
end

function game_1_2_1_1_Scene:ctor()
    print("ctor")
    local function sceneEventHandler(eventType)
        if eventType == "enter" then
            self:onEnter()
        elseif eventType == "exit" then
            self:onExit()
        end
    end
    self:registerScriptHandler(sceneEventHandler)
    self._role = nil
    self._Panel_root = nil
    self._quesTable = {{1,1},{1,2},{1,3},{1,4},{2,1},{2,2},{2,3},{3,1},{3,2},{4,1}}
    self._nowQues = nil -- 当前的题目
    self.isTouchableOrNot = nil
    self.score = 0
    self.littleGameTimes = nil    -- 小游戏运行了几个
    self._maxNum = 5
    self._sleepId = nil
    self._actionName = nil
    self.buttonBear = nil
    self._panel_car1 = nil -- 两辆汽车
    self._panel_car2 = nil
    self._car1_num = 0 -- 计数器数字
    self._car2_num = 0 
    self._tobeDelelePigs = {} -- 要删除的小猪
    self._nowBoxes = nil -- 所有的箱子
    self._shadowTable = {} -- 影子
    self.nowBoxesIndex = nil -- 小猪当前所在箱子
    self.aaaa=false -- 限制移动猪的过程中重复触摸
    self.bbbb=false
    self.cccc=false
    self._isBingo=true
    self._aniDate={
        stand={ani={"think","standby_1","standby_2"},loop=false,music=nil,musicId=nil},
        chuo={ani="chuo",loop=false,music="click.mp3",musicId=nil},
        bingo={ani="end_start",loop=false,music=nil,musicId=nil},
        bingo2={ani="end_ing",loop=false,music=nil,musicId=nil},
        bingo3={ani="end_end",loop=false,music=nil,musicId=nil},
        right={ani="right",loop=false,music="right2.mp3",musicId=nil},
        wrong={ani="wrong",loop=false,music="wrong2.mp3",musicId=nil},
        think={ani="think",loop=false,music="think.mp3",musicId=nil},--??
        sleepstart={ani="sleep_1",loop=false,music=nil,musicId=nil},
        sleeping={ani="sleep_2",loop=true,music="sleeping2.mp3",musicId=nil},
        wakeiup={ani="sleep_3",loop=false,music=nil,musicId=nil}
    }
end

function game_1_2_1_1_Scene:onEnter()
    print("on scene enter")
    self.isTouchableOrNot = false
    -- 初始化画面
    self._uiLayer = cc.Layer:create()
    self:addChild(self._uiLayer)
    self:runAction(cc.Sequence:create(cc.DelayTime:create(0.1),cc.CallFunc:create(function()
        --        cc.Director:getInstance():getTextureCache():addImage("class2-02-B1.png")
        --        ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("class2-02-E/class2-02-E.ExportJson")
        ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("ani/kuma_little/kuma_little.ExportJson")
        cc.Director:getInstance():getTextureCache():addImage("game_1_2_1_1/game_1_2_1_1_pig.png")
        cc.Director:getInstance():getTextureCache():addImage("game_1_2_1_1/game_1_2_1_1_shadow.png")
        for i=0, 5 do
        	cc.Director:getInstance():getTextureCache():addImage("game_1_2_1_1/game_1_2_1_1_"..i..".png")
        end
        for i=1, 4 do
            cc.Director:getInstance():getTextureCache():addImage("game_1_2_1_1/game_1_2_1_1_bus"..i..".png")
        end
        self:init()
    end)))


end

function game_1_2_1_1_Scene:onExit()
    cclog("game_1_2_1_1_Scene--->onExit")
    --    cc.Director:getInstance():getTextureCache():removeTextureForKey("class2-02-B1.png")
    cc.Director:getInstance():getTextureCache():removeTextureForKey("game_1_2_1_1/game_1_2_1_1_pig.png")
    cc.Director:getInstance():getTextureCache():removeTextureForKey("game_1_2_1_1/game_1_2_1_1_shadow.png")
        for i=0, 5 do
            cc.Director:getInstance():getTextureCache():removeTextureForKey("game_1_2_1_1/game_1_2_1_1_"..i..".png")
        end
        for i=1, 4 do
            cc.Director:getInstance():getTextureCache():removeTextureForKey("game_1_2_1_1/game_1_2_1_1_bus"..i..".png")
        end
    ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("ani/kuma_little/kuma_little.ExportJson")
    ccs.SceneReader:destroyInstance()
    ccs.ActionManagerEx:destroyInstance()
    ccs.GUIReader:destroyInstance()
    ccs.ArmatureDataManager:destroyInstance()

end

function game_1_2_1_1_Scene:init()
    cclog("==========>init")
    local m_scene_root = ccs.SceneReader:getInstance():createNodeWithSceneFile("game_1_2_1_1_Scene.json")
    self:addChild(m_scene_root)

    self._Panel_root = m_scene_root:getChildByTag(10003):getChildByTag(2)
    self._panel_car1 = self._Panel_root:getChildByName("busPanel"):getChildByName("Panel_car_1")
    self._panel_car2 = self._Panel_root:getChildByName("busPanel"):getChildByName("Panel_car_2")

    cclog("ppppp::"..#self._panel_car1:getChildren())
    self.littleGameTimes = 1
    self:SceneInit()
    self:runAction(cc.Sequence:create(cc.DelayTime:create(2),cc.CallFunc:create(function()
        self.isTouchableOrNot = true
    end)))
end

--播放动画
function game_1_2_1_1_Scene:playAction(_type)
    if _type==self._aniDate.stand then
        local function callBack()
            cclog("sleep===>")
            self._state=GameState.sleep
            self:playAction(self._aniDate.sleepstart)
        end
        if self._sleepId==nil then
            self._sleepId=self:runAction(cc.Sequence:create(cc.DelayTime:create(15),cc.CallFunc:create(callBack)))
        end
    else
        if self._sleepId~=nil then
            self:stopAction(self._sleepId)
            self._sleepId=nil
        end
    end

    local aniNames=_type.ani
    local loop=_type.loop
    local musicName=_type.music
    if musicName~=nil then
        cclog("musicName-->"..musicName)
    end
    if type(aniNames)=="table" then
        math.randomseed(tostring(os.time()):reverse():sub(1, 6))
        aniNames=aniNames[math.random(2,3)]
        --        if aniNames=="standby_1" then musicName= "look2.mp3" end
        --if aniNames=="standby_2" then musicName="look.mp3" end
        --print("rrrr:"..aniNames)
    end
    if self._actionName==_type and _type~=self._aniDate.stand then print("return") return end
    for k,v in pairs(self._aniDate) do
        if v.musicId~=nil then
            AudioEngine.stopEffect(v.musicId)
            v.musicId=nil
        end
    end
    self._actionName=_type
    --    cclog("aniNames----->"..aniNames)
    self._role:getAnimation():play(aniNames)
    if musicName~=nil then
        _type.musicId=AudioEngine.playEffect(musicName,_type.loop)
    end
end

-- 初始化画面
function game_1_2_1_1_Scene:SceneInit()
    this = self
    self:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(function() 
        AudioEngine.playMusic("game2.mp3",true)
    end)))
    -- 动画
    ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("ani/kuma_little/kuma_little.ExportJson")
    ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("ani/kuma_little/kuma_little.ExportJson")
    self._role=ccs.Armature:create("kuma_little")
    self._Panel_root:addChild(self._role,2)
    self._role:setPosition(cc.p(1000,300))
    self._role:setScale(0.5)
    local function animationEvent(armatureBack,movementType,movementID)
        local id = movementID
        if movementType == ccs.MovementEventType.loopComplete or movementType==ccs.MovementEventType.complete then
            if id == "standby"  or id=="standby_1" or id=="standby_2" then
                --            print("jinru")
                self:playAction(self._aniDate.stand)
            end
            if id=="chuo" then
                self:playAction(self._aniDate.stand)
                self._state=GameState.nomal
            end
            if id=="think" then
                self:playAction(self._aniDate.stand)
            end
            if id=="wrong" then
                -- cclog("adadas")
                -- self:FinalcallBack()
                self:playAction(self._aniDate.stand)
                self._state=GameState.nomal

            end
            if id=="right" or id=="end_end"then
                cclog("----------creteNumber>")

                self:playAction(self._aniDate.stand)
                --                self._state=GameState.nomal
            end
            if id=="end_start" then
                AudioEngine.playEffect("yeah1.mp3",false)
                self:playAction(self._aniDate.bingo2)
            end
            if id=="end_ing" then
                self:playAction(self._aniDate.bingo3)
            end
            if id=="sleep_1" then
                self:playAction(self._aniDate.sleeping)
            end
            if id=="sleep_3" then
                --                AudioEngine.stopEffect(self.musicId)
                if self._nextAction~=nil then
                    --                cclog("adada")
                    self:playAction(self._nextAction)
                    self._nextAction=nil
                else
                    --                    cclog("adadadadad")
                    self:playAction(self._aniDate.stand)
                end
            end
        end
    end
    self._role:getAnimation():setMovementEventCallFunc(animationEvent)
    self:playAction(self._aniDate.stand)
    self.buttonBear = self._Panel_root:getChildByName("Button_Bear")
    self.buttonBear:setOpacity(0)
    self.buttonBear:addTouchEventListener( function ( pSender, eventType )
        if self._isTouchableOrNot ==false then return end
        if eventType ~= ccui.TouchEventType.ended then return  end
        if eventType == ccui.TouchEventType.ended then
            if self.isTouchableOrNot == false then return end
            cclog("----buttonBear_touchdown")
            if self._actionName==self._aniDate.stand then --站立被点击
                self:playAction(self._aniDate.chuo)
            end
            if self._state==GameState.sleep then --睡觉被点击
                self:playAction(self._aniDate.wakeiup)
                --AudioEngine.stopEffect(self.musicId)
                self._state=GameState.nomal
            end
        end
    end)
    self:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(function() 
        self:InitGame()
    end)))
    

end

function game_1_2_1_1_Scene:InitQues()
    local t_index = math.random(1,#self._quesTable)
    self._nowQues = self._quesTable[t_index]
    table.remove(self._quesTable,t_index)
end

function game_1_2_1_1_Scene:InitPigs()
    -----------触摸事件
    -- 触摸开始
    local function touch(pSender, touchEventType)
        local nstr = pSender:getName()
        cclog("---ss-->"..nstr)
        local sdx,sdy= self._Panel_root:getChildByName("sd"..nstr):getPosition()
        self.widgetLastNodeSpace = cc.p(sdx,sdy) 
        cclog("---sdx-->"..sdx.."!---sdy-->"..sdy)

        if touchEventType == ccui.TouchEventType.began  then
            print("---------------------------TOUCH_EVENT_BEGAN")
            if self._sleepId~=nil then
                self:stopAction(self._sleepId)
                self._sleepId=nil
            end
            local function nosleepFunc()
                if self._state==GameState.sleep then
                    self._nextAction=self._aniDate.stand
                    self:playAction(self._aniDate.wakeiup)
                    self._state = GameState.nomal
                end
            end
            self:runAction(cc.Sequence:create(cc.DelayTime:create(0.0),cc.CallFunc:create(nosleepFunc)))
            if self.aaaa == true then return end
            if self.isTouchableOrNot == false then cclog("还不可以触摸") self.notMove =true return end
            if self.IsSwitchOrNot == true then cclog("正在切换。") return end

            pSender:setLocalZOrder(500)
            local worldSpace = pSender:convertToWorldSpace(cc.p(pSender:getContentSize().width/2,
                pSender:getContentSize().height/2))
            --print("/././",worldSpace.x,worldSpace.y)
            self.widgetLastWorldSpace = worldSpace
            --print("ddddd/././",this.widgetLastWorldSpace.x,this.widgetLastWorldSpace.y)

            -- 存放当前控件的相对位置
            local _x,_y = pSender:getPosition()
            print(".he.......",_x,_y)


            -- 存储当前触摸控件的父节点
            --            self.lastWidgetParent = pSender:getParent()
            self.movePoint = pSender:getTouchBeganPosition()
            cclog("self.movePoint(began):"..self.movePoint.x)
            self.notMove =false

        elseif touchEventType == ccui.TouchEventType.moved then
            print("---------------------------TOUCH_EVENT_MOVED")
            if self.bbbb == true then return end
            if self.isTouchableOrNot == false then self.notEd = true return end
            if self.notMove ==true then cclog("hhhbbb") return end
            if self.IsSwitchOrNot == true then cclog("正在切换。") return end
            --            if self.bbbb == true then return end

            cclog("self.movePoint(move):"..self.movePoint.x)
            self.lastPoint = self.movePoint
            self.movePoint = pSender:getTouchMovePosition()
            --            cclog("vvl;"..self.lastPoint)
            --            cclog("lll;"..self.movePoint)

            local offset = cc.pSub(self.movePoint, self.lastPoint)
            local x__,y__ = pSender:getPosition()
            local toPoint = cc.pAdd(cc.p(x__,y__),offset)
            pSender:setPosition(toPoint)
            self.notEd =false

        else

            print("---------------------------TOUCH_EVENT_ENDED")
            if self.cccc==true then return end
            if self.isTouchableOrNot == false then return end
            if self.notEd ==true then return end
            if self.IsSwitchOrNot == true then cclog("正在切换。") return end
            if self.cccc==true then return end
            self.aaaa=true
            self.bbbb=true
            self.cccc=true

            local function contactLogic() -- 接触后的处理逻辑
                self.IsSwitchOrNot = true
                self.aaaa=false
                self.bbbb=false
                self.cccc=false
                pSender:setOpacity(0)

                pSender:setPosition(cc.p(1882,888))
                table.insert(self._tobeDelelePigs,#self._tobeDelelePigs+1,pSender)
                cclog("========>"..self.nowBoxesIndex)
                AudioEngine.playEffect("jinru.mp3")

                local mubiao = self._nowBoxes[self.nowBoxesIndex]
                mubiao:setOpacity(255)
                local worspace = mubiao:convertToWorldSpaceAR(cc.p(0,0))
                local p =cc.ParticleSystemQuad:create("particle/game_1_2_1_1/game_1_2_1_1_jinru2.plist")
                p:setPosition(worspace)
                self._Panel_root:addChild(p,333)
                local name = self._nowBoxes[self.nowBoxesIndex]:getParent():getName()
                local musicFunc = {
                    [1] = function() AudioEngine.playEffect("one.mp3") end,
                    [2] = function() AudioEngine.playEffect("two.mp3") end,
                    [3] = function() AudioEngine.playEffect("three.mp3") end,
                    [4] = function() AudioEngine.playEffect("four.mp3") end,
                    [5] = function() AudioEngine.playEffect("five.mp3") end
                }
                if string.sub(name,11,11) == "1" then
                    self._car1_num = self._car1_num+1

                    musicFunc[self._car1_num]()
                    self._nowBoxes[self.nowBoxesIndex]:getParent():getChildByTag(566):loadTexture("game_1_2_1_1_"..self._car1_num..".png")
                else
                    self._car2_num = self._car2_num+1
                    musicFunc[self._car2_num]()
                    self._nowBoxes[self.nowBoxesIndex]:getParent():getChildByTag(566):loadTexture("game_1_2_1_1_"..self._car2_num..".png")
                end

                table.remove(self._nowBoxes,self.nowBoxesIndex)
                self.IsSwitchOrNot = false
                if #self._nowBoxes==0 then
                    if self._state==GameState.sleep then
                        self._nextAction=self._aniDate.bingo
                        self:playAction(self._aniDate.wakeiup)
                        --                        AudioEngine.stopEffect(self.musicId)
                    else
                        self:playAction(self._aniDate.bingo)
                    end

                    self.score = self.score + 20
                    cclog("self.littleGameTimes:"..self.littleGameTimes)
                    
                    cc.Director:getInstance():getRunningScene():movePer(self.score,cc.p(0,0))
                    local function readFunc()
                        AudioEngine.playEffect("fenjie"..self._nowQues[1].."-"..self._nowQues[2]..".mp3")
                    end
                    self:runAction(cc.Sequence:create(cc.DelayTime:create(1.0),cc.CallFunc:create(readFunc),cc.DelayTime:create(3.0),cc.CallFunc:create(function()
                        AudioEngine.playEffect("slideclose.mp3")
                        ccs.ActionManagerEx:getInstance():playActionByName("game_1_2_1_1_Ui_1.json","gate_down",cc.CallFunc:create(function()
                            local sum = self._Panel_root:getChildByName("Image_sum")
                            sum:setOpacity(0)
                            AudioEngine.playEffect("bus_departs.mp3")
                            ccs.ActionManagerEx:getInstance():playActionByName("game_1_2_1_1_Ui_1.json","bus_Out",cc.CallFunc:create(function()
                                -- 为下一题初始化
                                if self.littleGameTimes == self._maxNum+1 then
                                    self:runAction(cc.Sequence:create(cc.DelayTime:create(0.0),cc.CallFunc:create(function()
                                        self.isTouchableOrNot =false
                                        self._role:getAnimation():gotoAndPause(1)
                                        if self._sleepId~= nil then
                                            self:stopAction(self._sleepId)
                                            self._sleepId=nil
                                        end
                                        self._perScene:endLayer(1,2,1,1,self.score)
                                        return
                                    end)))
                                    return

                                end
                                self:InitGame()
                            end))
                        end))
                    end)))
                end
            end

            --            local desti = self._Panel_root:getChildByName("Panel_ques"):getChildByName("Image_2")
            --            local DesPos = desti:convertToWorldSpaceAR(cc.p(0,0))
            --            cclog("desposX:"..DesPos.x..",desposY:"..DesPos.y)
            local _x_,_y_ = pSender:getPosition()
            local worldSpace = pSender:convertToWorldSpaceAR(cc.p(0,0))
            --            local rectDes = cc.rect(DesPos.x-162,DesPos.y-140,316,289)
            local rectpSender = cc.rect(worldSpace.x,worldSpace.y-145,316,290)--cc.rect(_x_-69,_y_-90,139,181)
            local noContact = false -- 所有位置都没有接触
            local times = 0
            for idx=1, #self._nowBoxes do
                local DesPos = self._nowBoxes[idx]:convertToWorldSpaceAR(cc.p(0,0))
                --              local DesPos = cc.p(box_x,box_y)
                if cc.pGetDistance(DesPos,worldSpace)<=50 then -- todo
                    self.nowBoxesIndex = idx

                    break
                else
                    times = times+1
                end
            end
            cclog("------->times:"..times)
            cclog("------->#self._nowBoxes:"..#self._nowBoxes)
            if times == #self._nowBoxes then
                noContact = true
            else
                noContact = false
            end
            if noContact == false then -- todo
                cclog("接触了")
                contactLogic()
            else
                print("未接触")
                AudioEngine.playEffect("rebound.mp3",false)
                cclog("----xx>"..self.widgetLastNodeSpace.x)
                local moveTo = cc.MoveTo:create(1.0,self.widgetLastNodeSpace)
                local ease = cc.EaseExponentialOut:create(moveTo)
                pSender:runAction(cc.Sequence:create(ease,cc.CallFunc:create(function()
                    pSender:setLocalZOrder(160)
                    self.aaaa=false
                    self.bbbb=false
                    self.cccc=false
                    self.notMove = true
                    self.notEd = true
                end)))
            end

        end
    end

    local function assign(posTab)
        if #self._tobeDelelePigs~=0 then -- 删除上次仓库中的猪
            for key, var in pairs(self._tobeDelelePigs) do
                var:removeFromParent(true)
        end
        self._tobeDelelePigs={}
        end

        if #self._shadowTable~=0 then -- 删除上次仓库中得轮廓
            for key, var in pairs(self._shadowTable) do
                var:removeFromParent(true)
        end
        self._shadowTable={}
        end
        for ik=1, #posTab do
            local image = ccui.ImageView:create("game_1_2_1_1/game_1_2_1_1_pig.png")
            image:setPosition(posTab[ik])
            image:addTouchEventListener(touch)
            image:setTouchEnabled(true)
            image:setName(""..ik)
            self._Panel_root:addChild(image,160)
            local image_shadow = ccui.ImageView:create("game_1_2_1_1_shadow.png")
            image_shadow:setPosition(posTab[ik])
            image_shadow:setName("sd"..ik)
            table.insert(self._shadowTable,#self._shadowTable+1,image_shadow)
            self._Panel_root:addChild(image_shadow,150)
        end
    end
    local action = {
        [2] = function() print("~~~2只猪~~~") assign({cc.p(560,422),cc.p(721,422)}) end,
        [3] = function() print("~~~3只猪~~~") assign({cc.p(489,429),cc.p(641,406),cc.p(791,429)}) end,
        [4] = function() print("~~~4只猪~~~") assign({cc.p(474,441),cc.p(584,386),cc.p(692,449),cc.p(819,393)}) end,
        [5] = function() print("~~~5只猪~~~") assign({cc.p(474,441),cc.p(557,382),cc.p(637,451),cc.p(728,389),cc.p(816,452)}) end
    }
    local sum = self._nowQues[1]+self._nowQues[2]
    action[sum](x)
end

function game_1_2_1_1_Scene:BusComeIn()
    AudioEngine.playEffect("bus_arrives.mp3")
    ccs.ActionManagerEx:getInstance():playActionByName("game_1_2_1_1_Ui_1.json","bus_In",cc.CallFunc:create(function()
        AudioEngine.playEffect("slideopen.mp3")
        self:playAction(self._aniDate.think)
        ccs.ActionManagerEx:getInstance():playActionByName("game_1_2_1_1_Ui_1.json","gate_up",cc.CallFunc:create(function()
            local sum = self._Panel_root:getChildByName("Image_sum")
            sum:loadTexture("game_1_2_1_1_"..(#self._nowBoxes)..".png")
            sum:setOpacity(255)
            self.IsSwitchOrNot = false
            self.isTouchableOrNot = true
        end))
    end))
end

function game_1_2_1_1_Scene:InitBuses()
    self._nowBoxes = {}
    local function addPos( pal,tab)
        for i=1,#tab do
            local img = ccui.ImageView:create("game_1_2_1_1_pig.png")
            img:setOpacity(0)
            img:setPosition(tab[i])
            pal:addChild(img,10)
            table.insert(self._nowBoxes,#self._nowBoxes+1,img)
        end

    end
    local action = {
        [1] = function(pal) addPos(pal,{cc.p(302,161)}) end,
        [2] = function(pal) addPos(pal,{cc.p(254,161),cc.p(352,161)}) end,
        [3] = function(pal) addPos(pal,{cc.p(205,157),cc.p(298,159),cc.p(390,160)}) end,
        [4] = function(pal) addPos(pal,{cc.p(175,157),cc.p(268,158),cc.p(360,161),cc.p(460,161)}) end
    }
    local function init_panel_car( pal,index)
        local lightPos = {cc.p(150,259),cc.p(150,259),cc.p(115,259),cc.p(85,259)} -- 四种车灯的位置
        local image_car = ccui.ImageView:create("game_1_2_1_1_bus"..index..".png")
        image_car:setPosition(267,144)
        pal:addChild(image_car,0)
        local image_light = ccui.ImageView:create("game_1_2_1_1_0.png")
        image_light:setPosition(lightPos[index])
        pal:addChild(image_light,1,566)

        action[index](pal)
    end
    local q1 = self._nowQues[1]
    local q2 = self._nowQues[2]

    -- 删除上次panel中的图片
    if #self._panel_car1:getChildren()~=0 then
        self._panel_car1:removeAllChildren()
    end
    if #self._panel_car2:getChildren()~=0 then
        self._panel_car2:removeAllChildren()
    end

    init_panel_car(self._panel_car1,q1)
    init_panel_car(self._panel_car2,q2)
end

function game_1_2_1_1_Scene:InitGame()
    self._car1_num = 0
    self._car2_num = 0 
    self.isTouchableOrNot = false
    self.IsSwitchOrNot = true
    self.notMove = true
    self.notEd = true
    self:InitQues()
    self:InitPigs()
    self:InitBuses()
    self:BusComeIn()
    -- 变更数据
    self.littleGameTimes = self.littleGameTimes +1
end

function crt_game_1_2_1_1_Scene()
    local _scene = game_1_2_1_1_Scene:createScene()
    return _scene
end